package com.ssy.lingxi.search.controller.feign;

import cn.hutool.core.bean.BeanUtil;
import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.search.api.model.request.CommoditySearchRequest;
import com.ssy.lingxi.search.api.model.request.CommoditySkuRequest;
import com.ssy.lingxi.search.api.model.response.CommoditySkuResponse;
import com.ssy.lingxi.search.service.ICommodityService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 模板服务类--商品
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/8/1
 */
@RestController
@RequestMapping("/search/feign")
public class SearchFeignController extends BaseController {

    @Resource
    private ICommodityService commodityService;

    /**
     * 查询商品sku信息
     * @param commoditySkuRequest 请求参数
     */
    @RequestMapping(value = "/searchCommodityList", method = RequestMethod.POST)
    public Wrapper<List<CommoditySkuResponse>> getCommoditySkuList(@RequestBody @Valid CommoditySkuRequest commoditySkuRequest) {
        CommoditySearchRequest commoditySearchRequest = BeanUtil.copyProperties(commoditySkuRequest, CommoditySearchRequest.class);
        return Wrapper.success(commodityService.getCommoditySkuList(commoditySearchRequest));
    }

}
